package main

import (
	"fmt"
	"sort"
)

func main() {
	var str = "你好 golong"
	sliceStr := []rune(str)
	sliceStr[0] = '您'
	fmt.Println(string(sliceStr))
	fmt.Println("-----------------------------------------------")

	// 选择排序
	var num = []int{22, 3, 23, 5, 6, 12, 831, 1222}
	for i := 0; i < len(num); i++ {
		for j := i + 1; j < len(num); j++ {
			if num[i] < num[j] {
				tmp := num[i]
				num[i] = num[j]
				num[j] = tmp
			}
		}
	}
	fmt.Println(num)
	fmt.Println("-----------------------------------------------")
	var num2 = make([]int, len(num))
	copy(num2, num)
	//冒泡排序
	for i := 0; i < len(num2); i++ {
		for j := 0; j < len(num2)-1-i; j++ {
			if num2[j] > num2[j+1] {
				tmp := num2[j]
				num2[j] = num2[j+1]
				num2[j+1] = tmp
			}
		}
	}
	fmt.Println(num2)
	fmt.Println("-----------------------------------------------")
	var num3 = make([]int, len(num))
	copy(num3, num)
	//sort.Ints(num3) 升序
	sort.Sort(sort.Reverse(sort.IntSlice(num3))) //降序
	fmt.Println(num3)
}
